package com.zkthink.ceres.member.controller;

import com.zkthink.base.R;
import com.zkthink.base.controller.SuperController;
import com.zkthink.ceres.member.dto.CeresRelationAcoountPageDTO;
import com.zkthink.ceres.member.dto.CeresRelationAcoountSaveDTO;
import com.zkthink.ceres.member.dto.CeresRelationAcoountUpdateDTO;
import com.zkthink.ceres.member.entity.CeresRelationAcoount;
import com.zkthink.ceres.member.service.CeresRelationAcoountService;
import com.zkthink.security.annotation.PreAuth;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


/**
 * <p>
 * 前端控制器
 * 关联客户表
 * </p>
 *
 * @author ck
 * @date 2022-03-10
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/ceresRelationAcoount")
@Api(value = "CeresRelationAcoount", tags = "关联客户表")
@PreAuth(replace = "ceresRelationAcoount:")
public class CeresRelationAcoountController extends SuperController<CeresRelationAcoountService, Long, CeresRelationAcoount, CeresRelationAcoountPageDTO, CeresRelationAcoountSaveDTO, CeresRelationAcoountUpdateDTO> {

    /**
     * Excel导入后的操作
     *
     * @param list
     */
    @Override
    public R<Boolean> handlerImport(List<Map<String, String>> list) {
        List<CeresRelationAcoount> ceresRelationAcoountList = list.stream().map((map) -> {
            CeresRelationAcoount ceresRelationAcoount = CeresRelationAcoount.builder().build();
            //TODO 请在这里完成转换
            return ceresRelationAcoount;
        }).collect(Collectors.toList());

        return R.success(baseService.saveBatch(ceresRelationAcoountList));
    }
}
